//
//  overload_++_operator.cpp
//  learnC++
//
//  Created by apple on 2018/6/5.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#include "overload_++_operator.hpp"

Digit& Digit::operator++(){
    ++m_digit;
    return *this;
}

Digit& Digit::operator--(){
    --m_digit;
    return *this;
}

Digit Digit::operator++(int)
{
//    Digit temp(m_digit);
    
    ++(*this);
    
    return *this;
}

//引用不能返回临时变量
Digit Digit::operator--(int)
{
//    Digit temp(m_digit);
    
    --(*this);
    
    return *this;
}

std::ostream& operator<< (std::ostream &out, const Digit &d)
{
    out << d.m_digit;
    return out;
}
